#include<bits/stdc++.h>
using namespace std;
#define all(x) (x).begin(),(x).end()
#define rall(x) (x).rbegin(),(x).rend()
const int N=2e5+10;
#define INF 0x3f3f3f3f;
typedef long long int ll;
#define close(); std::ios::sync_with_stdio(false);cin.tie(0),cout.tie(0);
//----------------------------------------------------------------------------//

int n;
int st[110];
void solve()
{
	
	memset(st,0,sizeof st);
	cin>>n;
	vector<int> v1;
	
	for(int i=0;i<n;i++)
	{
		int x;
		cin>>x;
		v1.push_back(x);
		x=abs(x);
		st[x]++;	
	}
	
	sort(v1.begin(),v1.end(),greater<int>());
	int sum=0;
	for(auto&k:v1)
	{
		if(k>0) sum++;
		else sum--;
		cout<<sum<<" ";
	}
	cout<<'\n';
	
	
	for(int i=1;i<=n;i++)
	{
		if(st[i]>=2)
		{
			int t=(st[i]/2);
			st[i]=st[st[i]%2];
			while(t--)
			{
				cout<<1<<" "<<0<<" ";
			}
		}
	}
	
	sum=0;
	for(int i=1;i<=n;i++)
	{
		if(st[i])
		{
			sum++;
			cout<<sum<<" ";
		}
	}
	cout<<'\n';
	
	
	

}

int main()
{
	close();
	int T; cin>>T;
	while (T--) solve();
	return 0;
}

